var express = require('express');
var router = express.Router();


var auth = function (req, res, next) {
	var cert = req.cert;
	if (cert.type === 'customer') {
		next();
	} else {
		res.render('system/login');
	}
};

/* GET home page. */
router.get('/:type', auth, function (req, res, next) {
	var title = '';
	var type = req.params.type;
	
	if (!type) {
		res.send(404);
		return;
	}
	
	switch (type) {
	case 'trades' :
		title = '工种';
		break;
	case 'ageLevel' :
		title = '年龄范围';
		break;
	case 'empiricLevel' :
		title = '经验范围';
		break;
	case 'eduLevel' :
		title = '学历';
		break;
	case 'provinces' :
		title = '省份';
		break;
	default:
		title = type;
	}
	
	var view = type === 'trades' ? 'system/config_trades' : 'system/config';
	
	res.render(view, {
		menus : req.menus,
		title : title,
		type : type
	});
});

module.exports = router;
